package com.tms.drivermanagement.controller;

import java.util.Date;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.tms.drivermanagement.domain.Drivermanagement;
import com.tms.drivermanagement.service.IDrivermanagementService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 司机管理Controller
 *
 * @author ruoyi
 * @date 2024-11-01
 */
@RestController
@RequestMapping("/drivermanagement")
public class DrivermanagementController extends BaseController
{
    @Autowired
    private IDrivermanagementService drivermanagementService;

    /**
     * 查询司机管理列表
     */
    @RequiresPermissions("drivermanagement:drivermanagement:list")
    @GetMapping("/list")
    public TableDataInfo list(Drivermanagement drivermanagement)
    {
        startPage();
        List<Drivermanagement> list = drivermanagementService.selectDrivermanagementList(drivermanagement);
        return getDataTable(list);
    }

    /**
     * 导出司机管理列表
     */
    @RequiresPermissions("drivermanagement:drivermanagement:export")
    @PostMapping("/export")
    public void export(HttpServletResponse response, Drivermanagement drivermanagement)
    {
        List<Drivermanagement> list = drivermanagementService.selectDrivermanagementList(drivermanagement);
        ExcelUtil<Drivermanagement> util = new ExcelUtil<Drivermanagement>(Drivermanagement.class);
        util.exportExcel(response, list, "司机管理数据");
    }

    /**
     * 获取司机管理详细信息
     */
    @RequiresPermissions("drivermanagement:drivermanagement:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(drivermanagementService.selectDrivermanagementById(id));
    }

    /**
     * 新增司机管理
     */
    @RequiresPermissions("drivermanagement:drivermanagement:add")
    @PostMapping
    public AjaxResult add(@RequestBody Drivermanagement drivermanagement)
    {
        drivermanagement.setStatus(1);
        return toAjax(drivermanagementService.insertDrivermanagement(drivermanagement));
    }

    /**
     * 修改司机管理
     */
    @RequiresPermissions("drivermanagement:drivermanagement:edit")
    @PutMapping
    public AjaxResult edit(@RequestBody Drivermanagement drivermanagement)
    {
        return toAjax(drivermanagementService.updateDrivermanagement(drivermanagement));
    }

    /**
     * 删除司机管理
     */
    @RequiresPermissions("drivermanagement:drivermanagement:remove")
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(drivermanagementService.deleteDrivermanagementByIds(ids));
    }
}
